let http = require('http')
let cp = require('child_process') // 子进程
let proess = require('process'); // 进程

let port = 3000;
let platform = proess.platform // 返回当前操作系统

// 启动服务
let app = http.createServer((req, res) => {
    // request 请求   response 响应
    res.writeHead(200, {'content-type': 'application/json'}); // 响应头
    res.end('Hello node1111你好～');
}).listen(port)
console.log(`服务已经成功启动，地址：http://localhost:${port}/`);
// cp.exec(`open http://localhost:${port}/`) // start
// console.log(proess.platform);  // platform 平台

if(platform === 'win32') {
    cp.exec(`start Firefox http://localhost:${port}/`) // start
}else {
    cp.exec(`open http://localhost:${port}/`)
}